home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / eplain / add-date < prev    next >
Text File  |  1993-12-06  |  541b  |  27 lines

  1. #!/bin/sh
  2. # Change placeholders to variations on the current date.  Assumes
  3. # various % constructs are recognized.
  4.  
  5. if test $# -lt 1
  6. then
  7.   echo "Usage: $0 [<file> <file> ...]"
  8.   exit 1
  9. fi
  10.  
  11. temp=${TMPDIR-/tmp}/adddate$$
  12.  
  13. for f in "$@"; do
  14.   sed -e s/REPLACE-WITH-MONTH-YEAR/"`date +'%B %Y'`"/ \
  15.       -e s/REPLACE-WITH-DAY-MONTH-YEAR/"`date +'%e %B %Y'`"/ \
  16.       -e s/REPLACE-WITH-DATE/"`date`"/ \
  17.       <$f >$temp
  18.   if cmp -s $f $temp; then
  19.     echo "$f: No REPLACE-WITH-<date>."
  20.     exit 1
  21.   fi
  22.   rm -f $f
  23.   mv $temp $f
  24. done
  25.  
  26. rm -f $temp
  27.